<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- Copyright © 1988-2023 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "Funding Free Software", the Front-Cover
Texts being (a) (see below), and with the Back-Cover Texts being (b)
(see below).  A copy of the license is included in the section entitled
"GNU Free Documentation License".

(a) The FSF's Front-Cover Text is:

A GNU Manual

(b) The FSF's Back-Cover Text is:

You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<title>Calls (GNU Compiler Collection (GCC) Internals)</title>

<meta name="description" content="Calls (GNU Compiler Collection (GCC) Internals)">
<meta name="keywords" content="Calls (GNU Compiler Collection (GCC) Internals)">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Option-Index.html" rel="index" title="Option Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="RTL.html" rel="up" title="RTL">
<link href="RTL-SSA.html" rel="next" title="RTL SSA">
<link href="Insns.html" rel="prev" title="Insns">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
div.example {margin-left: 3.2em}
span:hover a.copiable-link {visibility: visible}
-->
</style>


</head>

<body lang="en">
<div class="section-level-extent" id="Calls">
<div class="nav-panel">
<p>
Next: <a href="RTL-SSA.html" accesskey="n" rel="next">On-the-Side SSA Form for RTL</a>, Previous: <a href="Insns.html" accesskey="p" rel="prev">Insns</a>, Up: <a href="RTL.html" accesskey="u" rel="up">RTL Representation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="RTL-Representation-of-Function_002dCall-Insns"><span>14.20 RTL Representation of Function-Call Insns<a class="copiable-link" href="#RTL-Representation-of-Function_002dCall-Insns"> &para;</a></span></h3>
<a class="index-entry-id" id="index-calling-functions-in-RTL"></a>
<a class="index-entry-id" id="index-RTL-function_002dcall-insns"></a>
<a class="index-entry-id" id="index-function_002dcall-insns"></a>

<p>Insns that call subroutines have the RTL expression code <code class="code">call_insn</code>.
These insns must satisfy special rules, and their bodies must use a special
RTL expression code, <code class="code">call</code>.
</p>
<a class="index-entry-id" id="index-call-usage"></a>
<p>A <code class="code">call</code> expression has two operands, as follows:
</p>
<div class="example smallexample">
<pre class="example-preformatted">(call (mem:<var class="var">fm</var> <var class="var">addr</var>) <var class="var">nbytes</var>)
</pre></div>

<p>Here <var class="var">nbytes</var> is an operand that represents the number of bytes of
argument data being passed to the subroutine, <var class="var">fm</var> is a machine mode
(which must equal as the definition of the <code class="code">FUNCTION_MODE</code> macro in
the machine description) and <var class="var">addr</var> represents the address of the
subroutine.
</p>
<p>For a subroutine that returns no value, the <code class="code">call</code> expression as
shown above is the entire body of the insn, except that the insn might
also contain <code class="code">use</code> or <code class="code">clobber</code> expressions.
</p>
<a class="index-entry-id" id="index-BLKmode_002c-and-function-return-values"></a>
<p>For a subroutine that returns a value whose mode is not <code class="code">BLKmode</code>,
the value is returned in a hard register.  If this register&rsquo;s number is
<var class="var">r</var>, then the body of the call insn looks like this:
</p>
<div class="example smallexample">
<pre class="example-preformatted">(set (reg:<var class="var">m</var> <var class="var">r</var>)
     (call (mem:<var class="var">fm</var> <var class="var">addr</var>) <var class="var">nbytes</var>))
</pre></div>

<p>This RTL expression makes it clear (to the optimizer passes) that the
appropriate register receives a useful value in this insn.
</p>
<p>When a subroutine returns a <code class="code">BLKmode</code> value, it is handled by
passing to the subroutine the address of a place to store the value.
So the call insn itself does not &ldquo;return&rdquo; any value, and it has the
same RTL form as a call that returns nothing.
</p>
<p>On some machines, the call instruction itself clobbers some register,
for example to contain the return address.  <code class="code">call_insn</code> insns
on these machines should have a body which is a <code class="code">parallel</code>
that contains both the <code class="code">call</code> expression and <code class="code">clobber</code>
expressions that indicate which registers are destroyed.  Similarly,
if the call instruction requires some register other than the stack
pointer that is not explicitly mentioned in its RTL, a <code class="code">use</code>
subexpression should mention that register.
</p>
<p>Functions that are called are assumed to modify all registers listed in
the configuration macro <code class="code">CALL_USED_REGISTERS</code> (see <a class="pxref" href="Register-Basics.html">Basic Characteristics of Registers</a>) and, with the exception of <code class="code">const</code> functions and library
calls, to modify all of memory.
</p>
<p>Insns containing just <code class="code">use</code> expressions directly precede the
<code class="code">call_insn</code> insn to indicate which registers contain inputs to the
function.  Similarly, if registers other than those in
<code class="code">CALL_USED_REGISTERS</code> are clobbered by the called function, insns
containing a single <code class="code">clobber</code> follow immediately after the call to
indicate which registers.
</p>
</div>
<hr>
<div class="nav-panel">
<p>
Next: <a href="RTL-SSA.html">On-the-Side SSA Form for RTL</a>, Previous: <a href="Insns.html">Insns</a>, Up: <a href="RTL.html">RTL Representation</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Option-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>
